<template>
  <div class="setting-shan-container">
    <el-button @click="upsqldate">升级数据库</el-button>
    <el-button @click="go('http://wen.juanpao.cn/web/#/1?page_id=35')">更新日志</el-button>
    <iframe height="750px" width="100%" frameborder=0 src="/upgrade.php">
        IE：你们都看我干吗，我现在也是支持的
    </iframe>
    <el-timeline>
      <el-timeline-item 
        v-for="(item, index) in logData" :key="index"
        :timestamp="item.create_time"
        placement="top">
        <h4>{{ item.title }}</h4>
        <p v-for="(s, count) in item.simple_info" :key="count">{{s}}</p>
      </el-timeline-item>
    </el-timeline>
  </div>
</template>

<script>
import { getUpLog, upsql } from '@/api/dashboard'
import { parseTime } from '@/utils'

export default {
  name: 'uplog',
  data() {
    return {
      logData: []
    }
  },
  // mounted() {
  //   var date = new Date(1574820623000);
  //   // new Date(1571657502)
  //   console.log(date);
  // },
  watch: {
    logData(val) {
      let arr = new Array();
      val.forEach(item => {
        item.create_time = parseTime(new Date(item.create_time*1000),'{y}-{m}-{d}');
        item.simple_info = item.simple_info.split('\n');
        arr.push(item);
      });
      return arr
    }
  },
  mounted() {
    this.getUpLog();
  },
  methods: {
    getUpLog() {
      getUpLog({app_id: 2}).then(res => {
        if(res.status === 200) {
          this.logData = res.data;
        }else{
          this.$message.error(res.status);
        }
      })
    },
    go (url) {
      location = url
    },
    upsqldate () {
      upsql().then(res => {
        this.$message(res.message);
      })
    }
  },

}
</script>

<style lang="scss" scoped>
.setting-shan-container{
  min-height: calc(100vh - 100px);
  margin: 20px;
  background-color: #fff;
  padding:25px;
  box-shadow: 0px 0px 4px 0px rgba(115, 115, 115, 0.2);
}
.applet-blendent-header{
  height: 40px;
  width: 100%;
  line-height: 40px;
  font-size: 16px; 
  font-weight: 600;
  letter-spacing: 2px;
  color: #8f8f8f;
  padding: 0 10px;
  background-color: #F4F8FB;
}
</style>